package com.xiaoshuidi.cloud.module.rooms.service;

import com.xiaoshuidi.cloud.framework.common.pojo.CommonResult;
import com.xiaoshuidi.cloud.framework.common.pojo.PageResult;
import com.xiaoshuidi.cloud.module.rooms.controller.admin.reservation.vo.*;
import com.xiaoshuidi.cloud.module.rooms.controller.app.reserve.vo.MyReservePageRespVO;
import com.xiaoshuidi.cloud.module.rooms.pojo.RoomHouseReserve;
import com.xiaoshuidi.cloud.module.rooms.pojo.RoomReserveWithdrawalDetail;
import com.xiaoshuidi.cloud.module.rooms.vo.ExportBaseVo;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 房源预定信息 服务类
 * </p>
 *
 * @author Feng
 * @since 2023-05-15
 */
public interface IRoomHouseReserveService {

    /**
     * 创建预定单
     *
     * @param req
     * @return
     */
    Long create(ReserveCreateReq req);

    /**
     * 根据房源信息获取最新一条待支付、已预订状态的预定单
     *
     * @param roomHouseId
     * @return
     */
    ReserveGetResp getByRoomId(Long roomHouseId);

    /**
     * 根据房源信息查询已签约、已取消的预定单列表
     *
     * @param roomHouseId
     * @param pageNo
     * @param pageSize
     * @return
     */
    PageResult<ReserveGetResp> page(Long roomHouseId, Integer pageNo, Integer pageSize);

    /**
     * 支付成功回调
     *
     * @param reserveId
     * @return
     */
    Boolean paymentSuccessful(Long reserveId, Long paymentId, LocalDateTime payTime,String payMethod);

    /**
     * 退订取消
     *
     * @param reserveId
     * @return
     */
    Boolean cancel(Long reserveId, String reason);

    /**
     * 修改
     *
     * @param req
     * @return
     */
    Boolean update(ReserveUpdateReq req);

    /**
     * 预定账单列表
     *
     * @param req
     * @return
     */
    PageResult<ReserveBillPageResp> billPage(ReserveBillPageReq req);

    /**
     * 根据id获取预定信息
     *
     * @param id
     * @return
     */
    ReserveGetResp get(Long id);

    /**
     * 预定账单导出
     *
     * @param req
     * @return
     */
    ExportBaseVo billExport(ReserveBillPageReq req);

    /**
     * 预定单导出
     *
     * @param req
     * @return
     */
    ExportBaseVo reserveExport(ReserveBillPageReq req);

    /**
     * 查询我的预定
     *
     * @param pageNum
     * @param pageSize
     * @param payState    支付状态 0:全部 1:待支付 2:已支付
     * @param bookerPhone
     * @return
     */
    CommonResult<PageResult<MyReservePageRespVO>> getMyReserve(Integer pageNum, Integer pageSize, Integer payState, String bookerPhone);

    /**
     * 根据用户ID获取预定信息
     *
     * @param userId   用户id
     * @param pageNo
     * @param pageSize
     * @return
     */
    PageResult<GetByUserIdRespVO> getByUserId(Long userId, Integer pageNo, Integer pageSize);

    void updateMember(Long userId, String mobile);

    RoomReserveExportResp templateDownload(Long apartmentId);

    CommonResult<String> reserveImport(String fileUrl);

    /**
     * 根据退定原因获取退定费用明细信息（下拉退定原因显示退定费用明细）
     * @param reserveId
     * @param reasonId
     * @return: java.util.List<com.xiaoshuidi.cloud.module.rooms.pojo.RoomReserveWithdrawalDetail>
     */
    List<RoomReserveWithdrawalDetail> getWithdrawDetail(Long reserveId, Integer reasonId);

    /**
     * 保存退定信息
     * @param reserveId
     * @param reasonId
     * @return: void
     */
    void reserveWithdraw(Long reserveId, Integer reasonId);

    /**
     * 退定账单支付
     * @param payReq
     * @return: void
     */
    void withdrawPay(ReserveWithdrawPayReq payReq);

    /**
     * 退定账单支付成功回调
     * @param reserveId
     * @param paymentId
     * @param payTime
     * @return: java.lang.Boolean
     */
    Boolean withdrawPaymentSuccessful(Long reserveId, Long paymentId, LocalDateTime payTime);

    /**
     * 退定账单列表
     *
     * @param req
     * @return
     */
    PageResult<ReserveBillPageResp> withdrawBillPage(ReserveBillPageReq req);

    /**
     * 根据Id获取退定费用明细信息
     * @param reserveId
     * @return: java.util.List<com.xiaoshuidi.cloud.module.rooms.pojo.RoomReserveWithdrawalDetail>
     */
    List<RoomReserveWithdrawalDetail> getWithdrawDetailById(Long reserveId);

    /**
     * 已支付预定单超时取消生成退定单
     * @param list
     * @return: void
     */
    void paidTimeOutCancel(List<RoomHouseReserve> list);
}
